package com.baizhi.staticx;

/**
 * Static修饰变量演示
 */
public class StaticDemo {
    public static void main(String[] args) {
        Student s1 = new Student();
        s1.name = "小张";
        s1.age = 9;
       // s1.grade = "四年级";
        Student.grade = "四年级";

       // s1.toStr();  //四年级

        System.out.println("-----------------------");

        Student s2 = new Student();
        s2.name = "小李";
        s2.age = 8;
       // s2.grade = "五年级";


        s1.toStr();  //五年级
        s2.toStr();

    }
}

/*
  代码格式化  Ctrl+Alt+L
 */
class Student {
    String name; //姓名
    int age; // 年龄

    //被static修饰的变量就叫做静态 变量
    static String grade; //年级

    public void toStr() {
        System.out.println(name + "\t" + age + "\t" + grade);
    }
}
